package main

import (
	"fmt"
	"time"
)

func main() {
	var a int = 3
	var b int = 2

	fmt.Println("下面是if  else ")
	if a >= 3 {
		fmt.Println(a)
	} else {
		fmt.Println(b)
	}

	a = 4

	fmt.Println("下面是if  else if")

	if a >= 3 {
		fmt.Println(a)
	} else if b >= 2 {
		fmt.Println(b)
	}

	fmt.Println("下面是if 嵌套")
	if a >= 4 {
		b = 3
		if b >= 3 {
			fmt.Println(b)
		}
	}

	fmt.Println("下面是switch")

	switch a {
	case 3:
		fmt.Println(a)
	case 4:
		fmt.Println(b)
	default:
		fmt.Println(b)
	}

	fmt.Println("下面是select")

	c1 := make(chan string)
	c2 := make(chan string)

	go func() {
		time.Sleep(1 * time.Second)
		c1 <- "one"
	}()
	go func() {
		time.Sleep(2 * time.Second)
		c2 <- "two"
	}()

	for i := 0; i < 2; i++ {
		select {
		case msg1 := <-c1:
			fmt.Println("received", msg1)
		case msg2 := <-c2:
			fmt.Println("received", msg2)
		}
	}

}
